import request from "@/utils/request";

// 查询所有角色
export const reqGetRoleListAPI = () => request.get("/park/sys/role");

// 获取树形结构
export const reqGetTreeAPI = () => request.get("/park/sys/permision/all/tree");

// 获取角色对应的权限
export const reqGetRolePermisionAPI = (roleID) =>
  request.get(`/park/sys/role/${roleID}`);

// 获取角色对应的用户
export const reqGetRoleUserAPI = (roleID, params) =>
  request.get(`/park/sys/roleUser/${roleID}`, { params });

/**
 * 创建角色
 * @returns
 */
export function createRoleUserAPI(data) {
  return request({
    url: `/park/sys/role`,
    method: "POST",
    data,
  });
}

export function updateRoleAPI(data) {
  return request({
    url: `/park/sys/role`,
    method: "PUT",
    data,
  });
}

// 删除角色
export const deleteRoleAPI = (id) => request.delete("/park/sys/role/" + id);

//查看用户列表
export const getUserListAPI = (params) =>
  request.get("/park/sys/user", { params });

// 添加用户
export const addUserAPI = (data) => request.post("/park/sys/user", data);

// 删除用户
export const deleteUserAPI = (id) => request.delete(`/park/sys/user/${id}`);

// 用户详情
export const getUserDetailAPI = (id) => request.get(`/park/sys/user/${id}`);

// 修改用户
export const updateUserAPI = (data) => request.put(`/park/sys/user`, data);
